package com.order.Controller;

import com.api.entity.UserCourseOrder;
import com.order.Mapper.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/*
    @ClassName Controller
    @Description TODO
    @Date 2021/9/3、10:47
*/
@RestController
@CrossOrigin
@RequestMapping("order")
public class OrderController {

    @Autowired
    private OrderMapper mapper;

    @RequestMapping("getOKOrderCourseIds/{userId}")
    public List<Integer> getOKOrderCourseIds(@PathVariable("userId")int userId){
        return mapper.getOrderByUserId(userId);
    }

    @RequestMapping("addorder/{courseid}/{userId}")
    public Integer addOrder(@PathVariable("courseid")int courseId,@PathVariable("userId")int userId){
        UserCourseOrder order = new UserCourseOrder();
        order.setUserId(userId);
        order.setCourseId(courseId);
        order.setStatus(20);
        return mapper.insert(order);
    }


}
